package edu.nf.ch01.factory;

import edu.nf.ch01.service.UserService;
import edu.nf.ch01.service.impl.TeacherServiceImpl;
import org.springframework.beans.factory.FactoryBean;

/**
 * @author wangl
 * @date 2025/4/27
 * 自定义FactoryBean对象，必须实现spring提供的FactoryBean接口
 */
public class TeacherServiceFactoryBean implements FactoryBean<UserService> {

    /**
     * 工厂方法，将创建的对象纳入容器管理
     * @return
     * @throws Exception
     */
    @Override
    public UserService getObject() throws Exception {
        return new TeacherServiceImpl();
    }

    /**
     * Bean的class类型
     * @return
     */
    @Override
    public Class<?> getObjectType() {
        return TeacherServiceImpl.class;
    }

    /**
     * 是否是以单例来管理(默认就是单例的)
     * @return
     */
    /*@Override
    public boolean isSingleton() {
        return true;
    }*/
}